#include<iostream>
#include<cstdio>
#define N 10000000
#define M 10
using namespace std;
int read()
{
	char c=0;
	int sum=0,f=1;
	while (c!='-'&&(c<'0'||c>'9')) c=getchar();
	if (c=='-') c=getchar(),f=-1;
	while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
	return sum*f;
}
int n,m,k,mod,ans,fac[N+1],invfac[N+1],inv[N+1],sw[N+1],dp[M+1][M+1],F[M+1],G[N+1],delta[N+1];
int MD(int x)
{
	return x>=mod?x-mod:x;
}
int MD2(int x)
{
	return x<0?x+mod:x;
}
void Adder(int &x,int d)
{
	x+=d;
	if (x>=mod) x-=mod;
	return;
}
void Adder2(int &x,int d)
{
	x+=d;
	if (x<0) x+=mod;
	return;
}
int fast_pow(int a,int b)
{
	int res=1,mul=a;
	while (b)
	{
		if (b&1) res=1ll*res*mul%mod;
		mul=1ll*mul*mul%mod,b>>=1;
	}
	return res;
}
int C(int x,int y)
{
	if (x<y) return 0;
	return 1ll*fac[x]*invfac[y]%mod*invfac[x-y]%mod;
}
int main()
{
	freopen("sequence.in","r",stdin);
	freopen("sequence.out","w",stdout);
	int res;
	n=read(),m=read(),k=read(),mod=read(),fac[0]=1;
	for (int i=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod;
	invfac[N]=fast_pow(fac[N],mod-2);
	for (int i=N-1;i>=0;--i) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
	for (int i=1;i<=N;++i) inv[i]=1ll*fac[i-1]*invfac[i]%mod;
	sw[n]=fast_pow(n,mod-2);
	for (int i=n-1;i>=0;--i) sw[i]=1ll*sw[i+1]*n%mod;
	if (k==0)
	{
		for (int i=0;i<=n;++i) Adder(ans,1ll*C(m+i-1,m-1)*C(n,i)%mod*fac[i]%mod*i%mod*sw[i]%mod);
		printf("%d\n",ans);
	}
	else if (k>0)
	{
		dp[0][0]=1;
		for (int i=0;i<=k;++i)
			for (int j=0;j<=i-1;++j)
			{
				Adder(dp[i][j],1ll*dp[i-1][j]*(j+1)%mod);
				if (j) Adder(dp[i][j],1ll*dp[i-1][j-1]*((i<<1)-1-j)%mod);
			}
		for (int i=0;i<=k-1;++i) F[i]=dp[k][i];
		G[0]=1;
		for (int i=0;i<=n-m-1;++i)
		{
			for (int j=0;j<=min(i,k-1);++j) Adder(delta[i],1ll*F[j]*G[i-j]%mod);
			if (i) Adder(delta[i],delta[i-1]);
			res=1ll*delta[i]*m%mod*((k<<1)+1)%mod;
			for (int j=max(i-k+2,0);j<=i;++j) Adder(res,1ll*G[j]*F[i-j+1]%mod*(i-j+1)%mod*m%mod);
			for (int j=1;j<=min(i,k-1);++j) Adder2(res,-1ll*F[j]*G[i-j+1]%mod*(i-j+1)%mod);
			G[i+1]=1ll*res*inv[i+1]%mod;
		}
		for (int i=m;i<=n;++i) Adder(ans,1ll*G[i-m]*C(n,i)%mod*fac[i]%mod*i%mod*sw[i]%mod);
		printf("%d\n",ans);
	}
	else
	{
		for (int i=1;i<=(-k);++i)
		{
			F[i]=fast_pow(i,i+k+mod-1);
			for (int j=1;j<=i-1;++j) Adder2(F[i],-1ll*F[j]*fast_pow(i,i-j-1)%mod*j%mod*C(i,j)%mod);
		}
		for (int i=1;i<=(-k);++i) F[i]=1ll*F[i]*invfac[i]%mod;
		G[0]=1;
		for (int i=0;i<=n-m-1;++i)
		{
			res=0;
			for (int j=max(i-(-k)+2,0);j<=i;++j) Adder(res,1ll*G[j]*F[i-j+2]%mod*(i-j+1)%mod*m%mod);
			for (int j=1;j<=min(i,(-k)-1);++j) Adder2(res,-1ll*F[j+1]*G[i-j+1]%mod*(i-j+1)%mod);
			G[i+1]=1ll*res*inv[i+1]%mod;
		}
		for (int i=m;i<=n;++i) Adder(ans,1ll*G[i-m]*C(n,i)%mod*fac[i]%mod*i%mod*sw[i]%mod);
		printf("%d\n",ans);
	}
	return 0;
}
